package cn.northsea.service.impl;


import cn.northsea.entity.RentChat;
import cn.northsea.mapper.RentChatMapper;
import cn.northsea.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ChatServiceImpl implements ChatService {

    @Autowired
    private RentChatMapper rentChatMapper;

    @Override
    public void addChatList(List<RentChat> chatList) {
        rentChatMapper.insertChatList(chatList);
    }

    @Override
    public List<RentChat> queryChatList(String username) {
        List<RentChat> chatListByUserName = rentChatMapper.findChatListByUserName(username);
        Collections.sort(chatListByUserName);
        return chatListByUserName;
    }

    @Override
    public void addChat(RentChat rentChat) {
        rentChatMapper.insertChat(rentChat);
    }
}
